package mate.business
{
	import com.asfusion.mate.actionLists.Scope;
	import com.asfusion.mate.core.GlobalDispatcher;
	
	import flash.events.Event;
	
	import mate.events.LoginEvent;
	
	import mx.collections.ArrayCollection;
	
	import spark.components.NavigatorContent;
	
	public class CmsManager
	{
		
		import classespinkpony.*;
		
		import mx.controls.Alert;
		import mx.rpc.Fault;
		
		private var _users:ArrayCollection;
		
		private var _professions:ArrayCollection;
		private var _specializations:ArrayCollection;
		private var _problems:ArrayCollection;
		private var _targets:ArrayCollection;
		
		private var _siteStatistics = new SiteStatistics();

		[Bindable]
		public function get siteStatistics()
		{
			return _siteStatistics;
		}

		public function set siteStatistics(value):void
		{
			_siteStatistics = value;
		}

		[Bindable]
		public function get users():ArrayCollection
		{
			return _users;
		}

		public function set users(value:ArrayCollection):void
		{
			_users = value;
		}
		
		public function storeSiteStatistics(siteStatsArray:Object):void
		{		
			if(siteStatsArray != null){
				siteStatistics = siteStatsArray[0];
			}
		}
		
		public function storeUsers(users:Object):void
		{		
			var temp:ArrayCollection = new ArrayCollection();
			if(users != null){
				for each (var user:User in users)
				{
					temp.addItem(user);		
				}
			}
			this.users = temp;
		}
		
		public function storeProfessions(profs:Object):void
		{		
			var temp:ArrayCollection = new ArrayCollection();
			if(profs != null){
				for each (var prof:Profession in profs)
				{
					temp.addItem(prof);		
				}
			}
			this.professions = temp;
		}
		
		public function storeSpecializations(specs:Object):void
		{		
			var temp:ArrayCollection = new ArrayCollection();
			if(specs != null){
				for each (var spec:Specialization in specs)
				{
					temp.addItem(spec);		
				}
			}
			this.specializations = temp;
		}
		
		public function storeProblems(probs:Object):void
		{		
			var temp:ArrayCollection = new ArrayCollection();
			if(probs != null){
				for each (var prob:Problem in probs)
				{
					temp.addItem(prob);		
				}
			}
			this.problems = temp;
		}
		
		public function storeTargets(targs:Object):void
		{		
			var temp:ArrayCollection = new ArrayCollection();
			if(targs != null){
				for each (var targ:Target in targs)
				{
					temp.addItem(targ);		
				}
			}
			this.targets = temp;
		}

		
		public function handleFault(fault:Fault):void{
			Alert.show(fault.faultString, fault.faultCode.toString());
		}

		[Bindable]
		public function get professions():ArrayCollection
		{
			return _professions;
		}

		public function set professions(value:ArrayCollection):void
		{
			_professions = value;
		}

		[Bindable]
		public function get specializations():ArrayCollection
		{
			return _specializations;
		}

		public function set specializations(value:ArrayCollection):void
		{
			_specializations = value;
		}

		[Bindable]
		public function get problems():ArrayCollection
		{
			return _problems;
		}

		public function set problems(value:ArrayCollection):void
		{
			_problems = value;
		}

		[Bindable]
		public function get targets():ArrayCollection
		{
			return _targets;
		}

		public function set targets(value:ArrayCollection):void
		{
			_targets = value;
		}


	}
}